package com.ysd.servlet;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.DdaoImpl;
import com.ysd.dao.impl.ProductclassifiCationTableDaoImpl;
import com.ysd.dao.impl.ProductdetailsinfoDaoImpl;
import com.ysd.entity.ProductclassifiCationTable;
import com.ysd.entity.Productdetailsinfo;


public class ProductsServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//产品分类
		ProductclassifiCationTableDaoImpl cDao = new ProductclassifiCationTableDaoImpl();
		List<ProductclassifiCationTable> list = cDao.gatProductclassifiCationTables();
		request.setAttribute("pc", list);
		
		//由id查询对应产品   ProductdetailsinfoDaoImpl
		int cid = Integer.parseInt(request.getParameter("catid"));
		ProductdetailsinfoDaoImpl pDao = new ProductdetailsinfoDaoImpl();
		List<Productdetailsinfo> Productdetailsinfo=pDao.Productdetailsinfo(cid);
		request.setAttribute("plist", Productdetailsinfo);
		//由id查询餐品分类
		int pid = Integer.parseInt(request.getParameter("catid"));
		DdaoImpl dDao = new DdaoImpl();
		List<ProductclassifiCationTable> fo=dDao.ProductclassifiCationTable(pid);
		request.setAttribute("list", fo);
		request.getRequestDispatcher("productlist.jsp").forward(request, response);
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
